<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>通知公告更改</title>
<link rel="stylesheet" type="text/css" href="../css/blueprint/screen.css" media="screen, projection"/>
<link rel="stylesheet" type="text/css" href="../css/blueprint/plugins/buttons/screen.css" media="screen, projection"/>
<script type="text/javascript" src="../script/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="../script/util.js"></script>
<script type="text/javascript">
var editorInstanceName;
$(document).ready(function() {
    $.ajax({
       type: "POST",
       url: "PrepareEditDoc.action",
       dataType: "json",
       success: function(data){
         $("#EDITOR_DIV").html(data.editorHtml);
         editorInstanceName = data.editorInstanceName;
         $("#TITLE_TEXT").val(data.docTitle);
         $("#DID_HIDDEN").val(data.did);
       }
    });
    $("#PUBLISH_BUTTON").click(function() {
    	publishDoc(editorInstanceName);
    });
});
function publishDoc(editor) {
   	var oEditor = FCKeditorAPI.GetInstance(editor);
   	var content = oEditor.GetXHTML();
    $.ajax({
       type: "post",
       url: "RePublishDoc.action",
       data: {"docId" : $("#DID_HIDDEN").val(), "docTitle": $("#TITLE_TEXT").val(), "docContent": content},
       dataType: "json",
       success: function(data){
           if (data.publishState == "null title") {
               alert('标题不能为空');
           } else if (data.publishState == "null content") {
        	   alert('内容不能为空');
           } else if (data.publishState == "success") {
        	   window.location.href="DocManage.html";
           }
       }
    });
}
</script>
</head>
<body>
<div style="width: 98%">
	<div style="width: 40%; float: left; text-align: left;">
		<input type="hidden" id="DID_HIDDEN"/>
		<span>标题：<input type="text" id="TITLE_TEXT" value="" size="30"/></span>
	</div>
	<div style="width: 20%; float: right;">
		<button style="margin-top: 0.5em;" id="PUBLISH_BUTTON"><img src="../css/blueprint/plugins/buttons/icons/page_add.png" alt=""/><span>发布</span></button>
	</div>
	<div style="float: right"></div>
</div>
<div id="EDITOR_DIV"></div>
</body>
</html>